package com.baiyichen.servlet;

import com.alibaba.fastjson.JSONArray;
import com.baiyichen.pojo.TiMu;
import com.baiyichen.service.TiMuServiceImpl;
import javafx.scene.image.Image;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Author:BaiYiChen
 * Date:2022/3/2216:48
 */
@Controller
@RestController
public class TiMuServlet {
  private TiMuServiceImpl serviceImpl;
  @Autowired
  public void setServiceImpl(TiMuServiceImpl serviceImpl) {
    this.serviceImpl = serviceImpl;
  }
  @RequestMapping(value = "/ti.do",produces = "text/application;charset=utf-8")
  public String TiMuData(int id, HttpServletRequest req, HttpServletResponse response) throws IOException {
    TiMu tiMu = serviceImpl.getTiMu(id);
    return JSONArray.toJSONString(tiMu);
  }
}
